<template>
  <div class="myLoadmore">
    <span v-if="!flag" @click="eV">{{msg}}</span>
    <span v-if="flag">加载中...</span>
  </div>
</template>
<script>
import * as Scorll from '../../utils/scroll'
export default {
  props: {
    // 是否请求
    flag: {
      required: true
    },
    // 请求是否成功
    ifFlag: {
      required: true
    }
  },
  methods: {
    eV () {
      this.$emit('event')
    }
  },
  mounted () {
    let thisVue = this;
    debugger;
    window.onscroll = function () {
      if (Scorll.getBottom() <= 30) {
      thisVue.eV()
      }
    }
  },
  computed: {
    // 请求失败变换显示内容
    msg () {
      if (this.ifFlag) {
        return '- 我也是有底线的 -'
      }
      return '加载失败,上拉重新加载!'
    }
  }
}
</script>

<style lang="scss">
@import '../../assets/styles/common.scss';
  .myLoadmore {
    width: 100%;
    text-align: center;
    cursor: pointer;
    padding: px2rem(20px) 0;
  }
</style>
